﻿namespace PowerSong.BibleSupport
    {

    /// <summary>
    /// Represents a specific Bible reference.
    /// </summary>
    public class BibleReference
        {

        /// <summary>
        /// Gets the Bible book name.
        /// </summary>
        /// <value>The name of the Bible book.</value>
        public BibleSupport.BibleBook Book { get; private set; }

        /// <summary>
        /// Gets the chapter number.
        /// </summary>
        /// <value>The chapter number.</value>
        public int Chapter { get; private set; }

        /// <summary>
        /// Gets the verse number.
        /// </summary>
        /// <value>The verse number.</value>
        public int Verse { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BibleReference" /> class.
        /// </summary>
        /// <param name="book">The book name.</param>
        /// <param name="chapter">The chapter number.</param>
        /// <param name="verse">The verse number.</param>
        public BibleReference(BibleSupport.BibleBook book, int chapter, int verse)
            {
            this.Book = book;
            this.Chapter = chapter;
            this.Verse = verse;
            }

        /// <summary>
        /// Returns a <see cref="System.String" /> that describes the reference in standard notation.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents the details of the Bible reference.
        /// </returns>
        public override string ToString()
            {

            var result = BibleSupport.GetBookName(Book);
            if (Chapter != -1)
                {
                result += " " + this.Chapter.ToString();
                if (Verse != -1) result += ":" + Verse.ToString();
                }
            return result;

            }

        /// <summary>
        /// Returns a <see cref="System.String" /> that describes the reference in standard notation, excluding verse details.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents the details of the Bible reference.
        /// </returns>
        public string ToChapterString()
            {

            string result = BibleSupport.GetBookName(Book);
            if (Chapter != -1)
                {
                result += " " + Chapter.ToString();
                }
            else
                {
                result += " 1";
                }
            return result;

            }

        }

    }
